from flask import Flask
from flask_migrate import Migrate, MigrateCommand
from flask_script import Manager

from models import db
from utils.common import news_style

from views import index_bp, passport_bp, user_bp

app = Flask(__name__)

app.config.from_pyfile('config.ini')
app.register_blueprint(index_bp)
app.register_blueprint(passport_bp)
app.register_blueprint(user_bp)
app.add_template_filter(news_style)
db.init_app(app)
manager = Manager(app)

# 生成migrate对象 用来数据库迁移
migrate = Migrate(app, db)
# 添加db命令
manager.add_command('db', MigrateCommand)

if __name__ == '__main__':
    manager.run()
